package com.mew.common.rest.mail;

import cn.hutool.core.date.DateUtil;
import com.mew.common.entity.mail.Accessory;
import com.mew.common.entity.mail.Mail;
import com.mew.common.util.DateUtils;
import com.zebra.common.ByteBufUtils;
import io.netty.buffer.ByteBuf;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author dylin
 * @create 2021/4/1
 */
@Data
@ToString
@NoArgsConstructor
public class MailBO extends Mail {
    private String gid;//发送人 姓名
    private String sendUserName;//发送人 姓名
    private Integer expirationTime;//过期时间
    private List<Accessory> accessoryList = new ArrayList<>();
    private int res;//预留 不同邮件不同处理
    @Override
    public void write(ByteBuf b) {
        super.write(b);
        ByteBufUtils.writeString(b,sendUserName==null?"":sendUserName);
        ByteBufUtils.writeInt(b,expirationTime);
        ByteBufUtils.writeInt(b,accessoryList.size());
        for (Accessory accessory : accessoryList) {
            accessory.write(b);
        }
        ByteBufUtils.writeInt(b,res);
    }
}
